bool InitializeDemo() { // Load the shader.
…
// Create the geometry. The layout of each vertex is made up // of just a position so that is all we need.
D3D10_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 }, };
…
DX10_Vertex vertices[] = { { D3DXVECTOR3( 0.0f, 0.5f, 0.5f), D3DXCOLOR(1, 0, 0, 1) }, { D3DXVECTOR3( 0.5f, -0.5f, 0.5f), D3DXCOLOR(0, 1, 0, 1) }, { D3DXVECTOR3(-0.5f, -0.5f, 0.5f), D3DXCOLOR(0, 0, 1, 1) }, }; // Create the vertex buffer.
D3D10_BUFFER_DESC buffDesc;
buffDesc.Usage = D3D10_USAGE_DEFAULT; buffDesc.ByteWidth = sizeof(DX10_Vertex) * 3; buffDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER; buffDesc.CPUAccessFlags = 0; buffDesc.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA resData; resData.pSysMem = vertices;
hr = g_d3dDevice->CreateBuffer(&buffDesc, &resData, &g_vertexBuffer);
if(FAILED(hr)) return false;
return true; }
|